package fl.ass.service.api;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import fl.ass.facade.api.IAssTrailCarFlowHistoryApi;
import fl.ass.facade.condition.AssTrailCarFlowHistoryQC;
import fl.ass.facade.dto.AssTrailCarFlowHistoryDTO;
import fl.ass.facade.dto.MessageDTO;
import fl.ass.service.service.IAssTrailCarFlowHistoryService;

/**
 * 处置转优车API
 * @author zy
 *
 */
@Component
public class AssTrailCarFlowHistoryApi implements IAssTrailCarFlowHistoryApi {
	
	private static final Logger logger = LoggerFactory.getLogger(AssTrailCarFlowHistoryApi.class);
	@Autowired
	private IAssTrailCarFlowHistoryService assTrailCarFlowHistoryService;
	@Override
	public List<AssTrailCarFlowHistoryDTO> searchAssTcFList(AssTrailCarFlowHistoryQC qc) {
		// TODO 自动生成的方法存根
		if(null == qc){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"查询对象不能为空!");
		}
		return this.assTrailCarFlowHistoryService.selectList(qc);
	}

	@Override
	public MessageDTO<String> updateAssTcF(List<AssTrailCarFlowHistoryDTO> dtos) {
		MessageDTO<String> response = new MessageDTO<String>();
		if(null == dtos){
			response.setMessage("parameter：dto is can not be null");
		}
		try {
			assTrailCarFlowHistoryService.updateAssTcF(dtos);
			response.setSuccess(true);
		} catch (Exception e) {
			BaseLogUtils.newLogger("批量更新数据失败!").setThrowable(e).info();
			response.setMessage(e.getMessage());
		}
		return response;
	}

	@Override
	public MessageDTO<String> batchInsert(List<AssTrailCarFlowHistoryDTO> dtos) {
		// TODO 自动生成的方法存根
		MessageDTO<String> response = new MessageDTO<String>();
		if(null == dtos){
			response.setMessage("parameter：dto is can not be null");
		}
		try {
			assTrailCarFlowHistoryService.batchInsert(dtos);
			response.setSuccess(true);
		} catch (Exception e) {
			BaseLogUtils.newLogger("批量插入数据失败!").setThrowable(e).info();
			response.setMessage(e.getMessage());
		}
		return response;
	}

	@Override
	public MessageDTO<String> batchDelete(List<Long> ids) {
		// TODO 自动生成的方法存根
		MessageDTO<String> response = new MessageDTO<String>();
		if(null == ids){
			response.setMessage("parameter：dto is can not be null");
		}
		try {
			assTrailCarFlowHistoryService.batchDelete(ids);			
			response.setSuccess(true);
		} catch (Exception e) {
            BaseLogUtils.newLogger("批量删除数据失败!").setThrowable(e).info();
			response.setMessage(e.getMessage());
		}
		return response;
	}

}
